﻿Imports DotNetNuke
Imports DotNetNuke.Common
Imports DotNetNuke.Services.Exceptions
Imports DotNetNuke.Services.Localization

Namespace DotNetNuke.Modules.Help
    Public Class EditHelpTutorialPresenter

#Region "Private Members"
        Private View As IEditHelpTutorial
        Private Controller As IHelpTutorialController
#End Region

#Region "Page Events"
        Public Sub New(ByVal _View As IEditHelpTutorial)
            View = _View
            Controller = New HelpTutorialController()
        End Sub

        Public Sub New(ByVal _View As IEditHelpTutorial, ByVal _Controller As IHelpTutorialController)
            View = _View
            Controller = _Controller
        End Sub

        Public Sub OnViewLoad(ByVal LoadForm As Boolean)
            Try
                ' '' If this is the first visit to the page, bind the role data to the datalist
                'If LoadForm = False Then

                '    If Not Utilities.Null.IsNull(View.ItemId) Then
                '        ' get content
                '        Dim objHelpTutorial As HelpTutorialInfo = Controller.GetHelpTutorial(View.ModuleId, View.ItemId)
                '        If Not objHelpTutorial Is Nothing Then
                '            View.EditorContent = objHelpTutorial.Content
                '            View.AuditCreatedByUser = objHelpTutorial.CreatedByUserName
                '            View.AuditCreatedDate = objHelpTutorial.CreatedDate.ToString
                '        Else ' security violation attempt to access item not related to this Module
                '            View.SecurityViolation = True
                '        End If
                '    Else
                '        View.DeleteButtonVisible = False
                '        View.AuditControlVisible = False
                '    End If
                'End If
            Catch exc As Exception
                View.Exception = exc
            End Try
        End Sub

        Public Sub OnCancel()
            View.Redirect = True
        End Sub

        Public Sub OnUpdate()
            Try

                'Dim objHelpTutorial As HelpTutorialInfo = New HelpTutorialInfo

                'objHelpTutorial.ModuleId = View.ModuleId
                'objHelpTutorial.ItemId = View.ItemId
                'objHelpTutorial.Content = View.EditorContent
                'objHelpTutorial.CreatedByUser = View.UserId

                'If Common.Utilities.Null.IsNull(View.ItemId) Then
                '    ' add the content within the HelpTutorial table
                '    Dim ItemId As Integer = Controller.AddHelpTutorial(objHelpTutorial)
                '    If ItemId = Null.NullInteger Then
                '        Throw New Exception("Add Exception")
                '    End If
                'Else
                '    ' update the content within the HelpTutorial table
                '    Controller.UpdateHelpTutorial(objHelpTutorial)
                'End If

                '' Redirect back to the portal home page
                'View.Redirect = True
            Catch exc As Exception    'Module failed to load
                View.Exception = exc
            End Try
        End Sub

        Public Sub OnDelete()
            Try
                '' Only attempt to delete the item if it exists already
                'Dim objHelpTutorial As HelpTutorialInfo = Controller.GetHelpTutorial(View.ModuleId, View.ItemId)
                'If Not objHelpTutorial Is Nothing Then
                '    Controller.DeleteHelpTutorial(View.ModuleId, View.ItemId)
                '    ' Redirect back to the portal home page
                '    View.Redirect = True
                'Else ' security violation attempt to access item not related to this Module
                '    View.SecurityViolation = True
                'End If
            Catch exc As Exception
                View.Exception = exc
            End Try
        End Sub

#End Region

    End Class
End Namespace

